diff options
Diffstat (limited to 'src/routes/projects/[projectId]/routine/[routineId]')
| -rw-r--r-- | src/routes/projects/[projectId]/routine/[routineId]/+page.svelte | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte b/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte index ea292ae..359fd5b 100644 --- a/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte +++ b/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte @@ -17,7 +17,18 @@ let frequency = $state(''); let description = $state(''); let note = $state(''); + let today = $state(''); + let day = $state(''); let saved = $state(false); + // Filled after mount: the server's timezone is not the viewer's. + $effect(() => { + if (today) return; + today = Temporal.Now.instant() + .toZonedDateTimeISO(Temporal.Now.timeZoneId()) + .toPlainDate() + .toString(); + day = today; + }); $effect(() => { name = data.routine.name; frequency = `${data.routine.frequencyDays}d`; @@ -160,6 +171,7 @@ use:enhance={() => { return async ({ update }) => { note = ''; + day = today; await update({ reset: false }); }; }} @@ -172,6 +184,14 @@ placeholder="Note (optionnel)" autocomplete="off" /> + <input + class="form-input done-date" + type="date" + name="doneAt" + bind:value={day} + max={today} + aria-label="Date de réalisation" + /> <Button variant="done" size="lg">Fait</Button> </form> {/if} @@ -244,10 +264,17 @@ .add-completion { flex-direction: row; align-items: center; + flex-wrap: wrap; } + /* Basis wider than the phone width so the note wraps instead of collapsing. */ .add-completion .form-input { - flex: 1; + flex: 1 1 12rem; + } + + .add-completion .done-date { + flex: 0 0 auto; + width: 11rem; } .completion-date { |
